/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class CreateVotoElectronicoData {
	public void createTestData() throws PersistentException {
		PersistentTransaction t = orm.VotoElectronicoPersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.CandidatoDAO lormCandidatoDAO = lDAOFactory.getCandidatoDAO();
			orm.Candidato[] lormCandidato = new orm.Candidato[30];
			for(int x=0;x!=lormCandidato.length;x++){
			lormCandidato[x]=lormCandidatoDAO.createCandidato();
			
			lormCandidato[x].setNombre("Candidato"+(x+1));
			lormCandidato[x].setRut(""+(x+1000));
			//lormCandidato.setVotos(0);
			lormCandidatoDAO.save(lormCandidato[x]);
			System.out.println("Agregado");
			}
			t.commit();
		
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public static void main(String[] args) {
		try {
			CreateVotoElectronicoData createVotoElectronicoData = new CreateVotoElectronicoData();
			try {
				createVotoElectronicoData.createTestData();
			}
			finally {
				orm.VotoElectronicoPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
